
<html>
<title> Views </title>
<body>
  <br/>
  <br/>
<?

  $sumRecvQty = 0;
  
  /**
  * Process the header 
  *
  */
  fetchLstDataHeader($COracle,
                     $jobId,
                     $srcDbHdr,
                     $nHeader,
                     $lstHeader);
  
?>
  
  <!--------------------- HEADER --------------------->
  <table border='1' class='dedeq'>
  <tr>
    <th> DATE       </th> <td> <?=$lstHeader["TR_DATE"][0] ?> </td>
    <th> SUPPLIER   </th> <td> <?=$lstHeader["SUPPLIER"][0] ?> </td>
  </tr>  
  <tr>
    <th> CURRENCY   </th> <td align ='right'> <?=$lstHeader["CURRENCY"][0] ?> </td>
    <th> RATE       </th> <td align ='right'> <?=$lstHeader["RATE"][0] ?> </td>
  </tr> 
  <tr>
    <th colspan='2'> MEMO       </th> <td colspan='2'> <?=$lstHeader["MEMO"][0] ?> </td>
  </tr>   
  </table>
  <br/>
  <!------------------ END Of HEADER ----------------->

<?
  /**
  * Process sub detail
  *
  */
  fetchLstDataSubDetail($COracle,
                        $jobId,
                        $srcDbDtlSub,
                        $nSubDetail,
                        $lstSubDetail);
  
?>

  <!------------------ SUB DETAIL -------------------->
  <table border='1' class='dedeq'>
    <tr>
    <th> NO       </th>
  <? if($_POST["transVariable"] == true): ?>
    <th> SELECT   </th>
  <? endif; ?>    
    <th> CAT      </th>
    <th> GRP      </th>
    <th> MODEL    </th>
    <th> UNIT     </th>
    <th> QTY      </th>
    <th> CVT      </th>
    <th> CVT-QTY  </th>
    <th> RECV-QTY </th>
    <th> PRICE    </th>
    <th> #        </th>
    </tr>
  <? for($iRow = 0; $iRow < $nSubDetail; $iRow++): ?>
    
    <tr>
      <td> <?=$lstSubDetail["NO"][$iRow] ?>       </td>
      
      <? if($_POST["transVariable"] == true): ?>
      <?   echo  "<td align='center'> ".formCheckBox( "passBox[]",
                                                      $lstSubDetail["NO"][$iRow],
                                                      _NO_PROPERTY)." </td>\n";
      ?>
      <? endif; ?>
      
      <td> <?=$lstSubDetail["ICAT"][$iRow] ?>     </td>
      <td> <?=$lstSubDetail["IGROUP"][$iRow] ?>   </td>
      <td> <?=$lstSubDetail["MODEL"][$iRow] ?>    </td>
      <td> <?=$lstSubDetail["UNIT"][$iRow] ?>     </td>
      <td> <?=$lstSubDetail["QTY"][$iRow] ?>      </td>
      <td> <?=$lstSubDetail["CVT_TO"][$iRow] ?>   </td>
      <td> <?=$lstSubDetail["CVT_QTY"][$iRow] ?>  </td>
      <td> <?=$lstSubDetail["RECV_QTY"][$iRow] ?> </td>
      <td> <?=$lstSubDetail["PRICE"][$iRow] ?>    </td>
      <td> <?=$lstSubDetail["HRZ_TOT"][$iRow] ?>  </td>
    </tr>
  
  <? /**
     * Sum up the received QTY
     *
     */
     $sumRecvQty += $lstSubDetail["RECV_QTY"][$iRow];
  ?>
  <? endfor; ?>
  <!-------------- END OF SUB DETAIL ----------------->
  
<?
  /**
  * Process detail
  *
  */
  fetchLstDataDetail($COracle,
                     $jobId,
                     $srcDbDtl,
                     $nDetail,
                     $lstDetail);

?>
  <!------------------- DETAIL ----------------------->
    <tr>
    <? if($_POST["transVariable"] == true): ?>
      <td colspan='6' align='right'><b> TOTAL </b></td>
    <? else: ?>
      <td colspan='5' align='right'><b> TOTAL </b></td>
    <? endif; ?>
      <td> <?=$lstDetail["TOT_QTY"][0] ?>     </td>
      <td> </td>
      <td> <?=$lstDetail["TOT_CVT_QTY"][0] ?> </td>
      <td> <?=$sumRecvQty ?> </td>
      <td> </td>
      <td> <?=$lstDetail["GRAND_TOT"][0] ?>   </td>
    </tr>
  <!----------------- END OF DETAIL ------------------>    
  </table>
</body>
<? $COracle->dc(); ?>

<!----------------- Additional Process --------------->
<?

/**
* If it is called by other module
* then we processed the return
*
*/
if($_POST["transVariable"] == 1){
  
  $CJs = new CGJavascript;
  
  /**
  * Properties of return will call ajax
  * to past the variables
  *
  */
  $propReturn = $CJs->jsOnClick("passVariables(\"passBox[]\",
                                               \"".$_POST["radioview"]."\");");
  
  $propClose  = $CJs->jsOnClick("window.close();");
  
  echo  formInputButton("Get",
                        "Get",
                        "Get",
                        $propReturn).
                        
        formInputButton("Close",
                        "Close",
                        "Close",
                        $propClose);
}
?>
</html>